package com.shop.admin.controller;

import com.shop.entity.dto.AdminUser.*;
import com.shop.entity.pojo.AdminUser;
import com.shop.admin.service.AdminUserService;
import com.shop.utils.common.enums.Code;
import com.shop.utils.common.result.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

@RestController
@RequestMapping("/user")
public class AdminUserController {

    @Autowired
    private AdminUserService adminUserService;

    @PostMapping("/login")
    public Result<String> login(@RequestBody AdminUserLoginDto dto){
        return adminUserService.login(dto);
    }

    @PostMapping("/get_admin_user_list")
    public Result getAdminUserList(@RequestBody AdminUserListDto dto){
        return adminUserService.getAdminUserList(dto);
    }

    @PostMapping("save_admin")
    public Result<AdminUser> add(@RequestBody AdminUserSaveDto dto){
        return adminUserService.add(dto);
    }

    @PostMapping("/remove_admin_user")
    public Result removeAdminUser(@RequestBody AdminUserRemoveDto dto){
        return adminUserService.removeAdminUser(dto);
    }

    @PostMapping("/update_get_admin_user")
    public Result<Map<String,Object>> updateGetAdminUser(@RequestBody AdminUserUpdateForGetDto dto){
        return adminUserService.updateGetAdminUser(dto);
    }

    @PostMapping("/update_admin_user")
    public Result<Map<String,Object>> updateAdminUser(@RequestBody AdminUserUpdateDto dto){
        return adminUserService.updateAdminUser(dto);
    }

    @GetMapping("/logout")
    public Result logout(){
        return Result.okResult(Code.SUCCESS);
    }

}
